home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Source / E / Demos / Intro.e < prev    next >
Encoding:
Text File  |  1998-03-30  |  3.1 KB  |  122 lines

  1. /* GMS-example
  2.  * Name: Intro.e
  3.  * Type: Screen/Picture/Fade example
  4.  * Version: 1.0
  5.  * Author: G. W. Thomassen (0000272e@lts.mil.no)
  6.  * Note: The file intro.pic is requiered to compile.
  7.  */
  8.  
  9. MODULE 'gms/dpkernel','gms/dpkernel/dpkernel','gms/graphics/pictures',
  10.        'gms/files/files','gms/screens','gms/system/register',
  11.        'gms/system/modules','gms/input/joydata','gms/graphics/screens',
  12.        'gms/graphics/blitter'
  13.  
  14. ENUM NONE,ERR_LIB,ERR_PIC,ERR_SCR,ERR_SCRMOD
  15.  
  16. PROC main() HANDLE
  17.   DEF fstate=NIL:LONG,
  18.       scr=NIL:PTR TO screen,
  19.       pic=NIL:PTR TO picture,
  20.       scrmodule=NIL:PTR TO module,
  21.       picfile:filename,
  22.       ft[30]:LIST,
  23.       col[30]:LIST,
  24.       up[30]:LIST,
  25.       speed[30]:LIST,i
  26.  
  27.  
  28.   -> Set up some colors and speed
  29.   FOR i:=1 TO 30
  30.     col[i]:=Rnd($FFFFFF)
  31.     speed[i]:=Rnd(9)+1
  32.     up[i]:=0
  33.   ENDFOR
  34.  
  35.   -> Set the picture file
  36.   picfile:=[ID_FILENAME,'GMS:Demos/Data/PIC.Intro']:filename
  37.  
  38.   -> Open the GMS-library
  39.   IF (dpkbase:=OpenLibrary('GMS:libs/dpkernel.library',0))=NIL THEN Raise(ERR_LIB)
  40.  
  41.   -> Open (init) the screen-module
  42.   IF (scrmodule:=Init([TAGS_MODULE,NIL,
  43.                    MODA_NUMBER,MOD_SCREENS,
  44.                    MODA_TABLETYPE,JMP_AMIGAE,
  45.                    TAGEND], NIL))=NIL THEN Raise(ERR_SCRMOD)
  46.  
  47.   scrbase:=scrmodule.modbase
  48.  
  49.  
  50.   -> Load the picture
  51.   IF (pic:=Load(picfile, ID_PICTURE))=NIL THEN Raise(ERR_PIC)
  52.  
  53.   -> Put the picture on the screen
  54.  
  55.   scr:=Get(ID_SCREEN)
  56.   CopyStructure(pic,scr)
  57.  
  58.   -> With black palette
  59.   scr.bitmap.palette := NIL
  60.   scr.bitmap.flags   := BMF_BLANKPALETTE
  61.  
  62.   -> Set up the screen
  63.   IF (scr:=Init(scr,NIL))=NIL THEN Raise(ERR_SCR)
  64.  
  65.   Copy(pic.bitmap,scr.bitmap)
  66.  
  67.   -> Display the screen
  68.   Show(scr)
  69.  
  70.   -> Fade to the picture palette
  71.   REPEAT
  72.     WaitAVBL()
  73.     fstate:=ColourToPalette(scr,fstate,2,0,scr.bitmap.amtcolours-128,pic.bitmap.palette+8,$000000);
  74.   UNTIL (fstate!=NIL)
  75.  
  76.  
  77.   -> Do something silly in the main loop
  78.   REPEAT;
  79.     WaitAVBL()
  80.     FOR i:=1 TO 30
  81.       IF up[i]=0 THEN ft[i]:=PaletteToColour(scr,ft[i],speed[i],i+127,1,pic.bitmap.palette+8,col[i])
  82.       IF up[i]=1 THEN ft[i]:=ColourMorph(scr,ft[i],speed[i],i+127,1,col[i],$000000)
  83.  
  84.       -> Set up new color when the last was reached..
  85.       IF ft[i]=NIL
  86.         IF up[i]=0
  87.           up[i]:=1
  88.         ELSE
  89.           col[i]:=Rnd($FFFFFF)
  90.           speed[i]:=Rnd(9)+1
  91.           up[i]:=0
  92.         ENDIF
  93.       ENDIF
  94.     ENDFOR
  95.     WaitAVBL()
  96.   UNTIL Mouse()=1
  97.  
  98.   -> fade to black..
  99.   REPEAT
  100.     WaitAVBL()
  101.     fstate:=PaletteToColour(scr,fstate,2,0,scr.bitmap.amtcolours-128,pic.bitmap.palette+8,$000000)
  102.     FOR i:=1 TO 30
  103.       IF ft[i]>NIL THEN ft[i]:=ColourMorph(scr,ft[i],speed[i],i+127,1,col[i],$000000)
  104.     ENDFOR
  105.   UNTIL (fstate!=NIL)
  106.  
  107.   Raise(NONE)     -> Exit with no error..
  108. -> handle errors
  109. EXCEPT DO
  110.   IF scr THEN Free(scr)
  111.   IF pic THEN Free(pic)
  112.   IF scrmodule THEN Free(scrmodule)
  113.   CloseDPK()
  114.   SELECT exception
  115.   CASE ERR_LIB; WriteF('Couldn''t open library\n')
  116.   CASE ERR_LIB; WriteF('Couldn''t open picturefile\n')
  117.   CASE ERR_LIB; WriteF('Couldn''t open screen\n')
  118.   CASE ERR_LIB; WriteF('Couldn''t initialize screen-module\n')  
  119.   ENDSELECT
  120.   CleanUp(0)
  121. ENDPROC
  122.